package model;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import dao.GetCnn;

import entity.Hoadon;

public class HoadonModel {
	public List<Hoadon> laycthd(String strSearch) throws SQLException{
		List<Hoadon> listhd = new ArrayList<Hoadon>();
		Connection cnn = GetCnn.getCnn();
		Statement stat = cnn.createStatement();
		
		ResultSet rs = stat.executeQuery(strSearch);
		while(rs.next()){
			Hoadon entity = new Hoadon();
			entity.setMahd(rs.getString("MAHD"));
			entity.setTensp(rs.getString("TENSP"));
			entity.setSoluong(rs.getInt("SOLUONG"));
			entity.setDongia(rs.getInt("DONGIA"));
			entity.setTrangthai(rs.getString("TRANGTHAI"));
			entity.setHoten(rs.getString("HOTEN"));
			listhd.add(entity);
		}
		return listhd;
	}
	public String getdoanhso(String strSearch) throws SQLException{
		String kq = "";
		Connection cnn = GetCnn.getCnn();
		Statement stat = cnn.createStatement();
		ResultSet rs = stat.executeQuery(strSearch);
		while(rs.next())
			kq = rs.getString("DOANHSO");
		return kq;
	}

}
